package kmi;

import static org.junit.Assert.assertEquals;
import robocode.control.testing.RobotTestBed;
import robocode.BattleResults;
import robocode.control.events.BattleCompletedEvent;

//import robocode.control.events.TurnEndedEvent;

/**
 * Illustrates JUnit testing of Robocode robots. To see output uncomment the last System out line in
 * test.
 * 
 * @author Mitchell Kupfer
 */

public class TestSittingDuck extends RobotTestBed {

  /**
   * Specifies that SittingDuck and green machine are to be matched up in this test case.
   * 
   * @return The comma-delimited list of robots in this match.
   */
  @Override
  public String getRobotNames() {
    return "sample.SittingDuck,kmi.GreenMachine";
  }

  /**
   * This test runs for 10 rounds.
   * 
   * @return The number of rounds.
   */
  @Override
  public int getNumRounds() {
    return 10;
  }

  /**
   * The actual test, which asserts that GreenMachine has won every round against SittingDuck.
   * 
   * @param event Details about the completed battle.
   */
  @Override
  public void onBattleCompleted(BattleCompletedEvent event) {
    // Return the results in order of getRobotNames.
    BattleResults[] battleResults = event.getIndexedResults();
    // Sanity check that results[1] is DaCruzer (not strictly necessary, but illustrative).
    BattleResults GreenMachineResults = battleResults[1];
    String robotName = GreenMachineResults.getTeamLeaderName();
    assertEquals("Check that results[1] is GreenMachine", robotName, "kmi.GreenMachine*");

  
    assertEquals("Check GreenMachine winner", GreenMachineResults.getFirsts(), getNumRounds());
  }
}
